
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1. Qt信号槽的概念 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../README_3.html" />
    
    
    <link rel="prev" href="../README_2.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Qt入门教程笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Chapter1/">
            
                <a href="../Chapter1/">
            
                    
                    一. Qt和qmake的配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Chapter1/1.1.html">
            
                <a href="../Chapter1/1.1.html">
            
                    
                    1. Qmake项目原理和手动配置Qtcreater
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Chapter1/1.2.html">
            
                <a href="../Chapter1/1.2.html">
            
                    
                    2. Qmake创建动态和静态链接库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../Chapter1/1.3.html">
            
                <a href="../Chapter1/1.3.html">
            
                    
                    3. Qmake的版本设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../README_2.html">
            
                <a href="../README_2.html">
            
                    
                    二. Qt信号槽机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="2.1.html">
            
                <a href="2.1.html">
            
                    
                    1. Qt信号槽的概念
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../README_3.html">
            
                <a href="../README_3.html">
            
                    
                    三. QWidget的概念和使用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Chapter3/3.1.html">
            
                <a href="../Chapter3/3.1.html">
            
                    
                    1. QWidget的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Chapter3/3.2.html">
            
                <a href="../Chapter3/3.2.html">
            
                    
                    2. QWidget的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../README_4.html">
            
                <a href="../README_4.html">
            
                    
                    四. QString字符串类型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Chapter4/4.1.html">
            
                <a href="../Chapter4/4.1.html">
            
                    
                    1. QString概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Chapter4/4.2.html">
            
                <a href="../Chapter4/4.2.html">
            
                    
                    2. QString方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../README_5.html">
            
                <a href="../README_5.html">
            
                    
                    五. QLabel
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Chapter5/5.1.html">
            
                <a href="../Chapter5/5.1.html">
            
                    
                    1. QLabel的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Chapter5/5.2.html">
            
                <a href="../Chapter5/5.2.html">
            
                    
                    2. QLabel的创建和方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../README_6.html">
            
                <a href="../README_6.html">
            
                    
                    六. QPushButton
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Chapter6/6.1.html">
            
                <a href="../Chapter6/6.1.html">
            
                    
                    1. QPushButton的概念
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1. Qt信号槽的概念</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="1-qt&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x6982;&#x5FF5;">1. Qt&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x6982;&#x5FF5;</h1>
<h2 id="11-&#x4FE1;&#x53F7;&#x69FD;&#x662F;&#x4EC0;&#x4E48;">1.1 &#x4FE1;&#x53F7;&#x69FD;&#x662F;&#x4EC0;&#x4E48;</h2>
<ol>
<li>&#x4FE1;&#x53F7;&#x69FD;&#x662F;&#x7A0B;&#x5E8F;&#x5185;&#x90E8;&#x4E0D;&#x540C;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x7684;&#x65B9;&#x5F0F;,&#x662F;&#x4E00;&#x79CD;&#x6D88;&#x606F;&#x673A;&#x5236;;</li>
<li>&#x4FE1;&#x53F7;&#x69FD;&#x662F;&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x7684;&#x4E00;&#x79CD;&#x5B9E;&#x73B0;&#xFF0C;&#x6216;&#x8005;&#x8BF4;&#x662F;&#x4E00;&#x79CD;&#x5347;&#x534E;&#xFF1B;</li>
<li>&#x4E00;&#x4E2A;&#x4FE1;&#x53F7;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x80FD;&#x591F;&#x88AB;&#x89C2;&#x5BDF;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x6216;&#x8005;&#x81F3;&#x5C11;&#x662F;&#x4E8B;&#x4EF6;&#x5DF2;&#x7ECF;&#x53D1;&#x751F;&#x7684;&#x4E00;&#x79CD;&#x901A;&#x77E5;&#xFF1B;</li>
<li>&#x4E00;&#x4E2A;&#x69FD;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x89C2;&#x5BDF;&#x8005;&#xFF0C;&#x901A;&#x5E38;&#x5C31;&#x662F;&#x5728;&#x88AB;&#x89C2;&#x5BDF;&#x7684;&#x5BF9;&#x8C61;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x7684;&#x65F6;&#x5019;&#x2014;&#x2014;&#x4E5F;&#x53EF;&#x4EE5;&#x8BF4;&#x662F;&#x4FE1;&#x53F7;&#x53D1;&#x51FA;&#x7684;&#x65F6;&#x5019;&#x2014;&#x2014;&#x88AB;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#xFF1B;</li>
<li>&#x4F60;&#x53EF;&#x4EE5;&#x5C06;&#x4FE1;&#x53F7;&#x548C;&#x69FD;&#x8FDE;&#x63A5;&#x8D77;&#x6765;&#xFF0C;&#x5F62;&#x6210;&#x4E00;&#x79CD;&#x89C2;&#x5BDF;&#x8005;-&#x88AB;&#x89C2;&#x5BDF;&#x8005;&#x7684;&#x5173;&#x7CFB;&#xFF1B;</li>
<li>&#x5F53;&#x4E8B;&#x4EF6;&#x6216;&#x8005;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4FE1;&#x53F7;&#x5C31;&#x4F1A;&#x88AB;&#x53D1;&#x51FA;&#xFF1B;&#x540C;&#x65F6;&#xFF0C;&#x4FE1;&#x53F7;&#x53D1;&#x51FA;&#x8005;&#x6709;&#x4E49;&#x52A1;&#x8C03;&#x7528;&#x6240;&#x6709;&#x6CE8;&#x518C;&#x7684;&#x5BF9;&#x8FD9;&#x4E2A;&#x4E8B;&#x4EF6;&#xFF08;&#x4FE1;&#x53F7;&#xFF09;&#x611F;&#x5174;&#x8DA3;&#x7684;&#x51FD;&#x6570;&#xFF08;&#x69FD;&#xFF09;&#x3002;</li>
</ol>
<h2 id="12-qt&#x4E2D;&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x5B9E;&#x73B0;">1.2 Qt&#x4E2D;&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x5B9E;&#x73B0;</h2>
<ol>
<li>&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x7EC4;&#x6210;</li>
<li>&#x4FE1;&#x53F7;&#x51FD;&#x6570;: &#x53EA;&#x53D1;&#x9001;&#x6D88;&#x606F;</li>
<li>&#x69FD;&#x51FD;&#x6570;</li>
<li><p>&#x8FDE;&#x63A5;&#x51FD;&#x6570;: &#x901A;&#x8FC7;QObeject&#x7684;&#x5B9A;&#x4E49;&#x6765;&#x8FDB;&#x884C;&#x7ED1;&#x5B9A;,&#x7531;moc&#x8FDB;&#x884C;&#x5B9A;&#x4E49;</p>
</li>
<li><p>&#x4FE1;&#x53F7;&#x548C;&#x69FD;&#x7684;&#x6D88;&#x606F;&#x4F20;&#x9012;&#x8FC7;&#x7A0B;</p>
</li>
<li>&#x7ED1;&#x5B9A;&#x4FE1;&#x53F7;&#x51FD;&#x6570;&#x548C;&#x69FD;&#x51FD;&#x6570;</li>
<li>&#x8C03;&#x7528;&#x4FE1;&#x53F7;&#x51FD;&#x6570;: &#x4FE1;&#x53F7;&#x51FD;&#x6570;&#x5C06;&#x4FE1;&#x53F7;&#x5199;&#x5165;&#x4FE1;&#x53F7;&#x5904;&#x7406;&#x7EBF;&#x7A0B;&#x7684;&#x6D88;&#x606F;&#x961F;&#x5217;</li>
<li>&#x4E3B;&#x7EBF;&#x7A0B;&#x8C03;&#x7528;&#x4FE1;&#x53F7;&#x961F;&#x5217;: &#x83B7;&#x5F97;&#x4FE1;&#x53F7;&#x5E76;&#x8C03;&#x7528;&#x4FE1;&#x53F7;&#x5BF9;&#x5E94;&#x7684;&#x69FD;&#x51FD;&#x6570;<blockquote>
<p>&#x7279;&#x522B;&#x7684;,&#x69FD;&#x51FD;&#x6570;&#x53EA;&#x80FD;&#x88AB;&#x4FE1;&#x53F7;&#x6240;&#x8C03;&#x7528;&#x800C;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x8C03;&#x7528;</p>
</blockquote>
</li>
</ol>
<p><img src="img1.png" alt="avatar"></p>
<h2 id="3-&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x5904;&#x7406;&#x4E3B;&#x5FAA;&#x73AF;">3. &#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x5904;&#x7406;&#x4E3B;&#x5FAA;&#x73AF;</h2>
<pre><code>QApplication a(argc,argv);

return a.exec();
</code></pre><p>&#x7531;QApplicaiton&#x7C7B;&#x4E2D;&#x7684;exec()&#x51FD;&#x6570;&#x76D1;&#x89C6;&#x6D88;&#x606F;&#x961F;&#x5217;</p>
<h2 id="4-&#x4FE1;&#x53F7;&#x69FD;&#x5B9E;&#x4F8B;">4. &#x4FE1;&#x53F7;&#x69FD;&#x5B9E;&#x4F8B;</h2>
<p>&#x6DFB;&#x52A0;&#x4FE1;&#x53F7;&#x69FD;&#x7684;&#x65B9;&#x6CD5;</p>
<ul>
<li>&#x8BBE;&#x8BA1;&#x5668;&#x6DFB;&#x52A0;(&#x62D6;&#x52A8;&#x548C;&#x6DFB;&#x52A0;,&#x518D;&#x9009;&#x62E9;&#x8BBE;&#x8BA1;&#x5668;&#x7684;&#x4FE1;&#x53F7;&#x69FD;&#x7F16;&#x8F91;&#x6A21;&#x5F0F;)</li>
<li>&#x4F7F;&#x7528;&#x5185;&#x90E8;&#x7684;&#x4FE1;&#x53F7;&#x69FD;&#x51FD;&#x6570;(&#x5982;&#x5B9E;&#x73B0;&#x5173;&#x95ED;&#x7A97;&#x53E3;)</li>
<li>&#x70B9;&#x51FB;&#x6309;&#x94AE;&#x624B;&#x52A8;&#x6DFB;&#x52A0;&#x69FD;&#x51FD;&#x6570;&#x81EA;&#x52A8;&#x7ED1;&#x5B9A;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;</li>
</ul>
<h2 id="5-&#x624B;&#x52A8;&#x6DFB;&#x52A0;&#x4FE1;&#x53F7;&#x69FD;">5. &#x624B;&#x52A8;&#x6DFB;&#x52A0;&#x4FE1;&#x53F7;&#x69FD;</h2>
<p>&#x901A;&#x8FC7;&#x8BBE;&#x8BA1;&#x5668;&#x6DFB;&#x52A0;&#x65B9;&#x4FBF;&#x76F4;&#x63A5;,&#x6BD4;&#x8F83;&#x5E38;&#x7528;,&#x4E5F;&#x53EF;&#x4EE5;&#x624B;&#x52A8;&#x6DFB;&#x52A0;&#x4FE1;&#x53F7;&#x69FD;.</p>
<ol>
<li>Q_OBJECT\
Q_OBJECT&#x662F;&#x4E00;&#x4E2A;&#x5B8F;, &#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x610F;&#x4E49;,&#x4F46;&#x53EF;&#x4EE5;&#x7ED9;moc&#x7A0B;&#x5E8F;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x6807;&#x8BC6;&#x7B26;,&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x4EE3;&#x7801;.</li>
<li>&#x624B;&#x52A8;&#x521B;&#x5EFA;&#x4FE1;&#x53F7;: &#x51FD;&#x6570;&#x524D;&#x6DFB;&#x52A0;&#x6807;&#x8BC6;&#x7B26;<code>signals</code>;</li>
<li>&#x624B;&#x52A8;&#x521B;&#x5EFA;&#x69FD;: &#x6807;&#x8BC6;&#x7B26;<code>public slots</code></li>
</ol>
<p>&#x6B65;&#x9AA4;:\</p>
<pre><code>1. &#x5728;project&#x7684;&#x5934;&#x6587;&#x4EF6;&#x7C7B;&#x91CC;&#x9762;&#x6DFB;&#x52A0;&#x4FE1;&#x53F7;&#x51FD;&#x6570;.\
```
signals:
    void sigFunc();//&#x53EA;&#x9700;&#x58F0;&#x660E;,&#x4E0D;&#x9700;&#x8981;&#x5B9A;&#x4E49;
```\
2. &#x540C;&#x6837;&#x5728;&#x7C7B;&#x91CC;&#x9762;&#x6DFB;&#x52A0;&#x69FD;&#x51FD;&#x6570;.
```
public slots:
    sigFunc();
```
&#x7136;&#x540E;&#x5728;&#x6E90;&#x4EE3;&#x7801;&#x91CC;&#x5BF9;&#x5176;&#x5B9A;&#x4E49;.\
3. &#x7ED1;&#x5B9A;&#x4FE1;&#x53F7;&#x51FD;&#x6570;&#x548C;&#x69FD;&#x51FD;&#x6570;.
- &#x4F7F;&#x7528;&#x8BBE;&#x8BA1;&#x5668;&#x8FDB;&#x884C;&#x7ED1;&#x5B9A;.
- &#x624B;&#x52A8;&#x7ED1;&#x5B9A;\
</code></pre><blockquote>
<p>&#x5728;project&#x7684;&#x6E90;&#x6587;&#x4EF6;&#x4E2D;\
<code>connect(this,SIGNAL(signalFun()),this,SLOT(slotFunc()));</code></p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../README_2.html" class="navigation navigation-prev " aria-label="Previous page: 二. Qt信号槽机制">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../README_3.html" class="navigation navigation-next " aria-label="Next page: 三. QWidget的概念和使用">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1. Qt信号槽的概念","level":"1.3.1","depth":2,"next":{"title":"三. QWidget的概念和使用","level":"1.4","depth":1,"path":"README_3.md","ref":"README_3.md","articles":[{"title":"1. QWidget的概念","level":"1.4.1","depth":2,"path":"Chapter3/3.1.md","ref":"Chapter3/3.1.md","articles":[]},{"title":"2. QWidget的使用","level":"1.4.2","depth":2,"path":"Chapter3/3.2.md","ref":"Chapter3/3.2.md","articles":[]}]},"previous":{"title":"二. Qt信号槽机制","level":"1.3","depth":1,"path":"README_2.md","ref":"README_2.md","articles":[{"title":"1. Qt信号槽的概念","level":"1.3.1","depth":2,"path":"Chapter2/2.1.md","ref":"Chapter2/2.1.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Chapter2/2.1.md","mtime":"2019-06-03T07:37:42.721Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-07T12:23:15.547Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

